package com.salt.security.wechat.auth;

import org.springframework.security.authentication.AbstractAuthenticationToken;

/**
 * 微信密码登陆
 *
 * @author HaiBo Kuang
 * @date 2021年04月21日 上午 10:05
 */
public class WeChatPasswordAuthenticationToken extends AbstractAuthenticationToken {
    private final String userNameOrPhone;
    private final String pwd;
    private final String openId;

    /**
     * 构造方法
     *
     * @param userNameOrPhone 用户名or电话
     * @param pwd             密码
     */
    public WeChatPasswordAuthenticationToken(String userNameOrPhone, String pwd, String openId) {
        super(null);
        this.userNameOrPhone = userNameOrPhone;
        this.pwd = pwd;
        this.openId = openId;
    }

    /**
     * 用户校验凭证
     *
     * @return 凭证
     */
    @Override
    public Object getCredentials() {
        return this.pwd;
    }

    /**
     * 认证主体
     *
     * @return 认证主体
     */
    @Override
    public Object getPrincipal() {
        return this.userNameOrPhone;
    }

    /**
     * 获取openId
     *
     * @return 结果
     */
    public String getOpenId() {
        return this.openId;
    }
}
